<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>父传子</title>
</head>
<body>
    <div id="app">
        <cpn :cmovies="movies" :cmessage="message"></cpn>
    </div>


    <template id="cpn">
        <div>
            {{cmovies}}
            <hr>
            {{cmessage}}
        </div>
    </template>

    <script src="../vue/vue.js"></script>
    <script>
        const cpn = {
            template:'#cpn',
            data() {
                return {
                    
                }
            },
            //1.普通传递
            //props:['cmovies'],
            //2.传递的时候进行:类型限制
            props:{
                cmovies:Array,
                cmessage:{
                    type:String, //类型为字符串
                    default:'aaaaa', //设置默认值
                    required:true //必须传入,否则报错   
                }
            }
        }
        const app = new Vue({
            el:'#app',
            data:{
                movies:['海王','看不见的客人','秘密访客'],
                message:'hello world!'
            },
            components:{
                cpn
            }
        });
    </script>
</body>
</html>